package com.ruoyi.web.controller.novel;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.SysNovelMoney;
import com.ruoyi.system.service.ISysNovelMoneyService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 资金明细列表Controller
 *
 * @author chj
 * @date 2022-11-10
 */
@RestController
@RequestMapping("/novel/money")
public class SysNovelMoneyController extends BaseController
{
    @Autowired
    private ISysNovelMoneyService sysNovelMoneyService;

    /**
     * 查询资金明细列表列表
     */
    @PreAuthorize("@ss.hasPermi('novel:money:list')")
    @GetMapping("/list")
    public TableDataInfo list(SysNovelMoney sysNovelMoney)
    {
        startPage();
        List<SysNovelMoney> list = sysNovelMoneyService.selectSysNovelMoneyList(sysNovelMoney);
        return getDataTable(list);
    }

    /**
     * 导出资金明细列表列表
     */
    @PreAuthorize("@ss.hasPermi('novel:money:export')")
    @Log(title = "资金明细列表", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, SysNovelMoney sysNovelMoney)
    {
        List<SysNovelMoney> list = sysNovelMoneyService.selectSysNovelMoneyList(sysNovelMoney);
        ExcelUtil<SysNovelMoney> util = new ExcelUtil<SysNovelMoney>(SysNovelMoney.class);
        util.exportExcel(response, list, "资金明细列表数据");
    }

    /**
     * 获取资金明细列表详细信息
     */
    @PreAuthorize("@ss.hasPermi('novel:money:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(sysNovelMoneyService.selectSysNovelMoneyById(id));
    }

    /**
     * 新增资金明细列表
     */
    @PreAuthorize("@ss.hasPermi('novel:money:add')")
    @Log(title = "资金明细列表", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody SysNovelMoney sysNovelMoney)
    {
        return toAjax(sysNovelMoneyService.insertSysNovelMoney(sysNovelMoney));
    }

    /**
     * 修改资金明细列表
     */
    @PreAuthorize("@ss.hasPermi('novel:money:edit')")
    @Log(title = "资金明细列表", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody SysNovelMoney sysNovelMoney)
    {
        return toAjax(sysNovelMoneyService.updateSysNovelMoney(sysNovelMoney));
    }

    /**
     * 删除资金明细列表
     */
    @PreAuthorize("@ss.hasPermi('novel:money:remove')")
    @Log(title = "资金明细列表", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(sysNovelMoneyService.deleteSysNovelMoneyByIds(ids));
    }
}
